# -*- coding:utf-8 -*-
'''
@author: xiaoming
@contact: lishihui0129@163.com
@time: 2017/6/28 10:37
@desc:操作mysql数据库
'''
import MySQLdb

conn=None
cursor = None
def connectDB():
    global conn
    conn=MySQLdb.connect(host="localhost",user="root",passwd="xiaoming",db="gongsi_etl",charset="utf8")
    global cursor
    cursor=conn.cursor()




def insertSql(sql,param):
    cursor.execute(sql,param)
    # return True

def close():
    cursor.close()
    conn.commit()
    conn.close()

# if __name__=='__main__':
#     sql="insert into url(url_value,prefix) values(%s,%s)"
#     param=("小明","ninshi")
#     insertSql(sql,param)
#     close()































# ceshi=[[(3,1)],[(2,5),(1,6)],[(3,7),(2,8),(1,1)]]
# # [[0,0,1],[6,5,0],[1,8,7]]
# res=[]
# for each in ceshi:
#     temp=[0]*3
#     for item in each:
#         temp[item[0]-1]=item[1]
#     res.append(temp)
# print res

